//
//  ProvinceModel.swift
//  MT
//
//  Created by M on 2019/12/23.
//  Copyright © 2019 张强. All rights reserved.
//

import UIKit

class ProvinceModel: NSObject {
    
    /// 省
    @objc public var province: String?
    
    /// 所有城市
    @objc public var cities: [CityModel]?

    init(dict: [String: Any]) {
        super.init()
        setValuesForKeys(dict)
    }
    
    override func setValue(_ value: Any?, forKey key: String) {
        if key == "cities" {
            var cities: [CityModel] = []
            if let values = value as? [[String:Any]] {
                for value in values {
                    let city = CityModel(dict: value)
                    cities.append(city)
                }
            }
            self.cities = cities
            return
        }
        super.setValue(value, forKey: key)
    }
    
}

class CityModel: NSObject {
    
    /// 区域
    @objc public var areas: [String]?
    
    /// 城市名
    @objc public var name: String?
    
    init(dict: [String: Any]) {
        super.init()
        setValuesForKeys(dict)
    }
    
}
